import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/langs/text_key.dart';

class SubscriptionFeatureTable extends StatelessWidget {
  const SubscriptionFeatureTable({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(20),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16),
      ),
      child: Table(
        columnWidths: const {
          0: FlexColumnWidth(2),
          1: FlexColumnWidth(1.5),
          2: FlexColumnWidth(1.5),
        },
        children: [
          _buildTableRow(
            [TextKey.subscriptionFeatureTableHeader.tr, TextKey.subscriptionFeatureTableGeneralDuration.tr, TextKey.subscriptionFeatureTableStorageSpace.tr],
            isHeader: true,
          ),
          _buildTableRow([TextKey.subscriptionFeatureTableGeneralDuration.tr, '30h/${TextKey.subscriptionMonth.tr}', '2h/${TextKey.subscriptionMonth.tr}']),
          _buildTableRow([TextKey.subscriptionFeatureTableStorageSpace.tr, '10GB', '1GB']),
          _buildTableRow([TextKey.subscriptionFeatureTableCloudFolder.tr, '10${TextKey.subscriptionItem.tr}', '1${TextKey.subscriptionItem.tr}']),
          _buildTableRow([TextKey.subscriptionFeatureTableCloudRecycleBin.tr, '15${TextKey.subscriptionDay.tr}', '✕']),
          _buildTableRow([TextKey.subscriptionFeatureTableShareSave.tr, '✓', '✕']),
          _buildTableRow([TextKey.subscriptionFeatureTableAISummary.tr, '✓', '✕']),
          _buildTableRow([TextKey.subscriptionFeatureTableAITranslation.tr, '✓', '✕']),
        ],
      ),
    );
  }

  TableRow _buildTableRow(List<String> cells, {bool isHeader = false}) {
    return TableRow(
      children: cells.map((cell) {
        return Padding(
          padding: const EdgeInsets.symmetric(vertical: 8),
          child: Text(
            cell,
            style: TextStyle(
              fontSize: 14,
              color: isHeader ? Colors.black : Colors.black54,
              fontWeight: isHeader ? FontWeight.bold : FontWeight.normal,
            ),
            textAlign: cells.indexOf(cell) == 0 
                ? TextAlign.left 
                : TextAlign.center,
          ),
        );
      }).toList(),
    );
  }
}